package unit3;

import java.util.Scanner;

/**
 * @version 1.0
 * @author asus
 *
 */
public class Retirement1 {
	public static void main(String[] args) {
//		read inputs
		@SuppressWarnings("resource")
		Scanner s=new Scanner(System.in);
		System.out.println("How much money do you need to retire?");
		double goal=s.nextDouble();
		
		System.out.println("How much money will you contirbute every year?");
		double payment=s.nextDouble();
		
		System.out.println("Interest rate in %:");
		double interestRate=s.nextDouble();
		
		double balance=0;
		int year=0;
		
//		update account balance while goal isn't reached
		while(balance<goal){
//			add this year's payment and interest 
			balance+=payment;
			double interest=balance*interestRate/100;
			balance+=interest;
			year++;
		}
		System.out.println("You can retire in "+year+"years.");
		
	}
}
